<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('文物管理列表')" />
    <style type="text/css">
    	.preview-img .tooltip-inner {
    		max-width: 400px;
    	}
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>文物名：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="museum:exhibit:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editFull()" shiro:hasPermission="museum:exhibit:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="museum:exhibit:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="museum:exhibit:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('museum:exhibit:edit')}]];
        var removeFlag = [[${@permission.hasPermi('museum:exhibit:remove')}]];
        var prefix = ctx + "museum/exhibit";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "文物管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '编号'
                },
                {
                    field: 'name',
                    title: '文物名'
                },
                {
                    field: 'type',
                    title: '文物类型'
                },
                {
                    field: 'url',
                    title: '3D链接'
                },
                {
                    field: 'remark',
                    title: '描述信息'
                },
                {
                    field: 'isImportant',
                    title: '重点文物',
                    align: 'center',
		            formatter: function(value, row, index) {
		                if (value == 0) {
		                    return '<span class="badge badge-primary">是</span>';
		                } else if (value == 1) {
		                    return '<span class="badge badge-danger">否</span>';
		                }
		            }
                },
                {
                    field: 'img',
                    title: '图片',
                    align: 'center',
                    class: 'preview-img',
		            formatter: function(value, row, index) {
		                if (value) {
// 		                    return '<span onmouseover="alert(1);" style="width:50px; height:50px; "><img src="'+value+'" style="width:50px; height:50px; "/></span>';
// 		                    return $.table.tooltip("<img src='/img/profile.jpg' style='height:100px'>" );
		                    return '<a data-toggle="tooltip" data-placement="bottom" title="<img src='+value+' style='+'height:200px'+'>" data-html="true"><span class="badge badge-primary">预览</span></a>';
		                } else {
		                    return '<span class="badge badge-primary">是</span>';
		                }
		            }
                    
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function typeTools(row) {
            let id = row.id;
            console.log(id);
            return [[${@exhibitType.getType(row)}]];
        }
    </script>
</body>
</html>